# Configuration
load_configuration
version_dir=$tmp_dir/versions
swap_version_file=$version_dir/swap
live_version_file=$version_dir/live
swap_version=UNKNOWN
live_version=UNKNOWN
swap_title=Swap
live_title=Live

mkdir -p $version_dir

$lftp_command <<MUNG
  $ftp_config
  echo "Fetching server data"
  open $ftp_host
  user $ftp_username $ftp_password
  get $ftp_swap_dir/version.frt -o $swap_version_file
  get $ftp_dir/version.frt -o $live_version_file
MUNG

if [ -f $swap_version_file ]
then
  swap_version=`head -n 1 $swap_version_file`
fi

if [ -f $live_version_file ]
then
  live_version=`head -n 1 $live_version_file`
fi

let swap_delim=${#swap_version}-${#swap_title}
let live_delim=${#live_version}-${#live_title}

if [ $swap_delim -lt 1 ]
then
  swap_delim=1
fi

if [ $live_delim -lt 1 ]
then
  live_delim=1
fi

i=0
while (( $i < $swap_delim ))
do
  shyph_delim="$shyph_delim-"
  snbsp_delim="$snbsp_delim "
  let i++
done

i=0
while (( $i < $live_delim ))
do
  lhyph_delim="$lhyph_delim-"
  lnbsp_delim="$lnbsp_delim "
  let i++
done

echo
echo "+-----$shyph_delim-+-----$lhyph_delim-+"
echo "| Swap$snbsp_delim | Live$lnbsp_delim |"
echo "+-----$shyph_delim-------$lhyph_delim-+"
echo "| $swap_version | $live_version |"
echo "+-----$shyph_delim-------$lhyph_delim-+"
echo

rm -rf $tmp_dir

